
<div class="febs-container">
    <div class="febs-open-body">
        <div class="layui-fluid" id="profile-update">
            <form class="layui-form" action="" lay-filter="profile-update-form">
                <div class="layui-form-item febs-hide">
                    <label class="layui-form-label febs-form-item-require">用户Id：</label>
                    <div class="layui-input-block">
                        <input type="text" name="userId" data-th-value="${user.userId}">
                    </div>
                </div>
                <div class="layui-form-item febs-hide">
                    <label class="layui-form-label febs-form-item-require">部门：</label>
                    <div class="layui-input-block">
                        <input type="text" name="deptId" data-th-value="${user.deptId}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <label class="layui-form-label layui-form-label-detail">所属公司：</label>
                            <div class="layui-input-block layui-input-block-html"  th:text="${user.tenantName}">
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label layui-form-label-detail">所属部门：</label>
                            <div class="layui-input-block layui-input-block-html" th:text="${user.deptName}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <label class="layui-form-label layui-form-label-detail">用户工号：</label>
                            <div class="layui-input-block layui-input-block-html" th:text="${user.userNo}">
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label layui-form-label-detail">登录账号：</label>
                            <div class="layui-input-block layui-input-block-html" th:text="${user.userName}">
                            </div>
                        </div>

                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md6">
                        <label class="layui-form-label febs-form-item-require">用户姓名：</label>
                        <div class="layui-input-block">
                            <input type="text" name="uname" minlength="2" maxlength="10" lay-verify="range"
                                   autocomplete="off" class="layui-input" placeholder="请输入用户姓名">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">身份证号：</label>
                        <div class="layui-input-block">
                            <input type="text" name="identificationNo" minlength="10" maxlength="64"
                                   autocomplete="off" class="layui-input" placeholder="请输入身份证号">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <label class="layui-form-label">用户手机：</label>
                            <div class="layui-input-block">
                                <input type="tel" name="mobile" lay-verify="phone" autocomplete="off" class="layui-input" placeholder="请输入用户手机号">
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <label class="layui-form-label">用户邮箱：</label>
                            <div class="layui-input-block">
                                <input type="text" name="email" lay-verify="email" maxlength="50" autocomplete="off"
                                       class="layui-input" placeholder="请输入用户邮箱">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <label class="layui-form-label febs-form-item-require">用户性别：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="sex" value="0" title="男性">
                                <input type="radio" name="sex" value="1" title="女性">
                                <input type="radio" name="sex" value="2" title="保密">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item febs-hide">
                    <button class="layui-btn" lay-submit="" lay-filter="profile-update-form-submit" id="submit"></button>
                </div>
            </form>
        </div>
    </div>
</div>

<script data-th-inline="javascript">
    layui.use(['febs', 'form', 'validate', 'treeSelect'], function () {
        var $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            treeSelect = layui.treeSelect,
            form = layui.form,
            user = [[${user}]],
            $view = $('#profile-update'),
            validate = layui.validate;
        form.verify(validate);
        form.render();
        initUserValue();

        function initUserValue() {
            form.val("profile-update-form", {
                "userName": user.userName,
                "uname": user.uname,
                "mobile": user.mobile,
                "email": user.email,
                "userNo": user.userNo,
                "identificationNo": user.identificationNo,
                "status": user.status,
                "sex": user.sex,
                "deptLeaderFlg": user.deptLeaderFlg,
                "userType": user.userType,
                "tenantName": user.tenantName,
                "deptName": user.deptName,
                "contractorId": user.contractorId,
                "contractorTeamId": user.contractorTeamId,
                "joinDate": user.joinDate,
                "description": user.description
            });


            if(user.contractorId){
                var data={
                    contractorId : user.contractorId
                }
                febs.getSync(ctx + 'baseContractorTeam', data, function (r) {
                    console.log("承包队列表"+JSON.stringify(r.data))
                    var contractorTeamList = r.data;
                    $.each(contractorTeamList,function (index,item) {
                        var options =  '<option value="'+item.contractorTeamId+'">'+item.teamName+'</option>'
                        $("#contractorTeamSelect").append(options);
                    })
                });
                $("#contractorTeamSelect").val(user.contractorTeamId);
                form.render();
            }
        }

        form.on('submit(profile-update-form-submit)', function (data) {
            if (febs.nativeEqual(data.field, user)) {
                febs.alert.warn('数据未作任何修改！');
                return false;
            }
            febs.modal.confirm("保存提示！","是否修改用户信息",function (index){
                febs.post(ctx + 'user/profile/update', data.field, function () {
                    layer.closeAll();
                    febs.modal.confirm('修改成功', '是否马上刷新页面生效？', function () {
                        window.location.reload();
                    });
                });
            })
            return false;
        });
    });
</script>